/**
 * 左上走到右下的方案总数。C(N+M-2, N-1)
 */
#include <bits/stdc++.h>
using namespace std;

using llt = long long;
using pll = pair<llt, llt>;

int const SZ = 10000010;
llt const MOD = 998244353LL;

llt qpow(llt a, llt n){
    llt ret = 1;
    a %= MOD;
    while(n){
        if(n & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ret;
}

inline llt inv(llt x){return qpow(x, MOD-2LL);}

vector<llt> Fac, IFac;

inline llt C(llt n, llt m){
    if(0 <= m and m <= n) return Fac[n] * IFac[n - m] % MOD * IFac[m] % MOD;
    return 0;
}



int N, M;

void work(){
    cin >> N >> M;
    auto n = N + M - 2;
    cout << C(n, N -1) << "\n";
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    Fac.assign(SZ, 0);
    IFac.assign(SZ, 0);
    Fac[0] = Fac[1] = 1;
    for(int i=1;i<SZ;++i) Fac[i] = Fac[i - 1] * i % MOD;
    IFac[SZ - 1] = inv(Fac[SZ - 1]);
    for(int i=SZ-2;i>=0;--i) IFac[i] = IFac[i + 1] * (i + 1) % MOD;
    assert(IFac[0] == 1 and IFac[1] == 1);

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    cin >> nofkase;
    while(nofkase--) work();
    return 0;
}
